use syn::{DeriveInput, Item, parse_quote};

#[test]
fn test_expand_api() {
    let input: Item = parse_quote! {
        impl TaskApi for TaskApiImpl {
            async fn get_by_id(self, req: Json<Req>) -> Result<Res, Infallible> {
                Ok(Res {
                    order_no: String::default(),
                })
            }

            async fn update_user(self, req: Json<Req>) -> Result<Res, Infallible> {
                Ok(Res {
                    order_no: String::default(),
                })
            }
        }
    };

    let result = carpet_expand::handler_attribute::impl_api_expand(input);
    println!("{}", result.unwrap());
}

#[test]
fn test_expand_handler() {
    let input: Item = parse_quote! {
        impl HandlerImpl {
            pub async fn _handle(self, req: Json<RequestData>) -> Result<ResponseData, Infallible> {
                Ok(ResponseData {
                    message: String::from("abc"),
                })
            }
        }
    };

    let result = carpet_expand::handler_attribute::impl_handler_expand(input);
    println!("{}", result.unwrap());
}

#[test]
fn test_derive() {
    let mut input: DeriveInput = parse_quote! {
        pub struct HandlerImpl {
            pub db: State<String>,
            pub ex: Extension<String>,
        }
    };

    let result = carpet_expand::handler_derive::expand(&mut input);
    println!("{}", result.unwrap());
}
